from elasticsearch_dsl import Document, Integer, Keyword, Text
from elasticsearch_dsl.connections import connections

connections.create_connection(hosts=['172.20.0.1:40002'])


class HouseInfoDoc(Document):
    site = Keyword()
    title = Text()
    pos = Keyword()
    price = Integer()
    floor = Text()
    build = Text()
    layout = Text()
    size = Text()
    direction = Keyword()
    follows = Text()
    published = Text()
    image_url = Keyword()
    file_name = Keyword()

    class Index:
        name = 'hsmarket'

    def save(self, **kwargs):
        return super().save(**kwargs)


if __name__ == '__main__':
    HouseInfoDoc.init()
